home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games 1996 July
/
Amiga Games 1996 #7.iso
/
spiele
/
publicdomain
/
knockout
/
knockout.amos
/
knockout.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1993-08-18
|
18KB
|
646 lines
' Knock Out
' ~~~~~~~~~
' by Ben Wyatt, bwyatt@paston.co.uk
' Requires Turbo (and probably Craft) extensions
' Has to be compiled for it to work :)
' Info for me:
' Screens
' 0 - Main circle screen
' 1 - Bridge drawing screen
' 2 - Dual playfield for "Fight!"
' 3 - Controls screen
' 4 - Game type options screen
Set Buffer 35
Degree
MXPL=8
If Prg State=-1
Break Off : Extension_12_0928 127 : Wait Vbl
Timer=0 : For N=1 To 50000 : Next N
If Timer>34 : MXPL=5 : End If
End If
Global MXPL,PL,CSIZE,AN,CAR,SAMREP,ZSTP,TPLAYER,KS,PLONK,GAMETYPE,BCOUNT,BDIR
Dec MXPL
Dim X(MXPL),Y(MXPL),XSP(MXPL),YSP(MXPL),ANG(MXPL),SPD(MXPL),CON(MXPL)
Dim WINS(MXPL),DI(MXPL),HIT(MXPL),SPRNUM(MXPL)
Global X(),Y(),XSP(),YSP(),ANG(),SPD(),CON()
Global WINS(),DI(),HIT(),SPRNUM()
Dim QSIN(31),QCOS(31),C(15),CF(7),CCOL(7),CSIN(359),CCOS(359),TWIDTH(9)
Global QSIN(),QCOS(),C(),CF(),CCOL(),CSIN(),CCOS(),TWIDTH()
Dim XPLAT1(45,32),XPLAT2(45,32),YPLAT(45,32),STLIM(4),ENLIM(4)
Global XPLAT1(),XPLAT2(),YPLAT(),STLIM(),ENLIM()
_GO
Procedure _GO
Def Fn _LEFT=Jleft(1) or Key State(26) or Key State(6) or Key State(100)
Def Fn _RIGHT=Jright(1) or Key State(27) or Key State(7) or Key State(102)
Def Fn _FIRE=Fire(1) or Key State(57) or Key State(35) or Key State(96)
PL=MXPL
_INIT
For N=0 To MXPL : CON(N)=6 : Next N
TIM=1 : GAMETYPE=0
Do
' Run demo, or game
Repeat
_START
_GAMEON
For N=0 To MXPL : CON(N)=Abs(CON(N)) : Next N
Until KS
For N=0 To MXPL : WINS(N)=0 : Next N
' Open a screen to display the game type options on
Screen Open 4,320,256,16,Lowres
Screen Hide 4
Screen Display 4,128,37,320,256
Flash Off : Curs Off : Cls 0
For N=0 To 15 : Colour N,$555 : Next N
Extension_12_058A 64,32,19
Screen Show 4
Fade 2,,$777,$AAA,$DDD,$0,$2AF,$F54,$2B3,$F90,$B22,$F22,$80,$D0,$CF,$7F,$2F
Repeat
Paste Icon 16,64+16,14-2*(GAMETYPE=0)
Paste Icon 160,64,15-2*(GAMETYPE=1)
If Fn _RIGHT and GAMETYPE<1 : GAMETYPE=1 : End If
If Fn _LEFT and GAMETYPE>0 : GAMETYPE=0 : End If
If Key State(69) : Edit : End If
Until Fn _FIRE
Fade 2,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
' Fade up the borders
For N=5 To 0 Step -1
Screen Display Screen,,,,
Colour Back N*256+N*16+N
Wait Vbl : Wait Vbl
Next N
Wait 12
PL=MXPL
If GAMETYPE=1 : PL=3 : End If
Screen Close 4
' Controls screen
Screen Show 3 : Screen To Front 3
Screen 3
Fade 2,$0,,,,,,,,,,,,,,,,$0,$111,$222,$333,$444,$555,$666,$777,$888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF
Wait 28
For N=0 To PL
If(TIM=1 and N<3) or GAMETYPE=1 : CON(N)=N+1 : End If
If CON(N)=7 : CON(N)=6 : End If
Fade 1,,,,,,,,,CCOL(N)
Repeat
For M=1 To 6 : Colour M,$F : Next M
If Fn _RIGHT and CON(N)>1 : Dec CON(N) : Wait 5 : End If
LIM=6 : If GAMETYPE=1 : LIM=5 : End If
If Fn _LEFT and CON(N)<LIM
Inc CON(N) : Wait 5
End If
Wait Vbl : Colour CON(N),$FF0
If Key State(69) : Edit : End If
Wait Vbl
Until Fn _FIRE
Repeat : Until Fn _FIRE=False
Next N
Fade 2,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555,$555
' Fade away the borders
For N=0 To 5
Screen Display Screen,,,,
Colour Back N*256+N*16+N
Wait Vbl : Wait Vbl
Next N
Wait 12
Screen Hide 3
Inc TIM
Loop
End Proc
Procedure _INIT
Colour Back $555
' Open a screen for drawing the bridge on
Screen Open 1,64,128,8,Lowres
Screen Hide 1
Flash Off : Curs Off : Cls 0
Ink 4
' Open a main screen
Screen Open 0,320,320+64,8,Lowres
Screen Display 0,128,37,320,256
Flash Off : Curs Off : Cls 0
Screen Hide 0
If Length(1)=0 : Load "Graphics.Abk" : End If
Get Bob Palette : Make Mask
Palette $555
If Length(2)=0 : Load "Icons.Abk" : End If
If Length(10)=0 : Load "Controls.Abk",10 : End If
If Length(5)=0 : Load "Samples.Abk",5 : End If
Sam Bank 5
Hide On
ZSTP=8
' Open a screen for the controls
Screen Open 3,320,256,32,Lowres
Screen Display 3,128,37,320,256
Flash Off : Curs Off : Cls 0
Screen Hide 3
Unpack 10,0,0 : Erase 10
For N=0 To 31 : Colour N,$555 : Next N
' Define the colours
CN=0
For N=0 To 3
Read C : C(N*4+1)=$0 : C(N*4+2)=C
CCOL(CN+1)=C : Inc CN
Read C : C(N*4+3)=C
CCOL(CN-1)=C : Inc CN
Next N
' Colour data
Data $F99,$F33,$F3F,$FA5,$39F,$FF3,$3F3,$3FF
' All the numbers and widths
For N=4 To 13
Make Icon Mask N
Next N
For N=0 To 9
Read TWIDTH(N)
Next N
Data 17,11,18,20,19,20,18,17,22,18
Screen Show 0
' Open a dual playfield screen
Screen Open 2,320,256,8,Lowres
Screen Display 2,128,37,320,256
Flash Off : Curs Off : Cls 0
Double Buffer : Autoback 0
Wait Vbl
Dual Playfield 0,2
Dual Priority 2,0
Screen 0
Volume %10,30
' Set Hot-Spots to centre of cars
For N=1 To Length(1)
Trap Hot Spot N,8,8
Next N
' Calculate sins/cosines
For N=0 To 359
CSIN(N)=Sin(N)*1024 : CCOS(N)=Cos(N)*1024
Next N
' Predefine all angles
For N=0 To 31
ANG=N*11.25
QSIN(N)=Sin(ANG)*2048 : QCOS(N)=Cos(ANG)*2048
Next N
' Work out the position of the bridge in all possible positions
For N=0 To 45
For SIZ=0 To 32
XPLAT1(N,SIZ)=16.1-(Cos(N*2)*16)/Max(4-SIZ/8,1)
XPLAT2(N,SIZ)=48+(Cos(N*2)*16)/Max(4-SIZ/8,1)
YPLAT(N,SIZ)=128-Sin(N*2)*(SIZ*4)
Next SIZ
Next N
' Calculate limits on car input movements
' so, cars only move every 4 frames
For N=0 To 3
STLIM(N)=PL/3.0*N : ENLIM(N)=PL/3.0*(N+1)
Next N
Amos To Front
End Proc
Procedure _START
For N=0 To PL
SPRNUM(N)=1+(N mod 2=0)*(0-280)
Next N
If GAMETYPE=1
CON(4)=7 : ANG(4)=0 : SPRNUM(4)=313 : X(4)=160*2048 : Y(4)=128*2048
XSP(4)=0 : YSP(4)=0
If MXPL>4
For N=5 To MXPL : CON(N)=-Abs(CON(N)) : ANG(N)=266*1024 : Next N
End If
End If
Screen 0
CSIZE=110+16*(GAMETYPE=1)
For N=0 To 15 : Colour N,$555 : Next N
For N=16 To 31 : Colour N,$AAA : Next N
Extension_12_0380 -1
Extension_12_045C 160,128,CSIZE,1
Ink 1 : Paint 160,128
For SIZE=1 To CSIZE Step 5
STP=2500/(2.0*Pi#*SIZE)
AN=Rnd(360)
For ANG=AN To 360-STP+AN Step STP
Paste Bob 157+Sin(ANG)*SIZE+Rnd(1),126+Cos(ANG)*SIZE,33+Rnd(7)
Next ANG
Next SIZE
PLONK=True
For N=0 To PL
ANG(N)=360/(PL+1)*N
X(N)=(160+Sin(ANG(N))*(CSIZE-16))*2048
Y(N)=(128+Cos(ANG(N))*(CSIZE-16))*2048
SPD(N)=0 : DI(N)=0
ANG(N)=(ANG(N)*2+360)/22.5 : XSP(N)=0 : YSP(N)=0
If ANG(N)>31 : Add ANG(N),-32 : End If
If CON(N)<>6 : PLONK=False : End If
Next N
If GAMETYPE=0
For D=0 To PL*8
C=Rnd(PL) : N=Rnd(PL)
Swap X(N),X(C) : Swap Y(N),Y(C) : Swap ANG(N),ANG(C)
Next D
End If
If PLONK
Screen 0
Colour 5,$9F
CF(4)=$A00 : CF(5)=$9F
For X=-34 To 0
Paste Icon X,0,1 : Wait Vbl
Next X
Else
CF(4)=C(3) : CF(5)=C(2) : CF(6)=C(7) : CF(7)=C(6)
If GAMETYPE=1
Cls 4,160-16,128+CSIZE To 160+16,128+CSIZE+32
Cls 5,160+CSIZE,128-16 To 160+CSIZE+32,128+16
Cls 6,160-16,129-CSIZE-32 To 160+16,129-CSIZE
Cls 7,161-CSIZE-32,128-16 To 161-CSIZE,128+16
End If
End If
Colour 9,$FF0
Wait 10
Screen 2
For N=80 To 0 Step -ZSTP
Extension_12_0380 -1
Paste Bob 160-80,106,265+N/ZSTP
Screen Swap : Wait Vbl
Next N
Screen 0
Fade 6,,$777,$AAA,$DDD,CF(4),CF(5),CF(6),CF(7),,$FF0 : Wait 30
Screen 2
For N=0 To 80 Step ZSTP
Extension_12_0380 -1
Paste Bob 160-80,106,265+N/ZSTP
Screen Swap : Wait Vbl
Next N
Extension_12_0380 -1 : Screen Swap
Extension_12_0380 -1 : Screen Swap
Screen 0
If GAMETYPE=1 : C(10)=$BB0
Else C(10)=$39F
End If
Fade 12,,,,,,,,,,,,,,,,,,C(1),C(2),C(3),,C(5),C(6),C(7),,C(9),C(10),C(11),,C(13),C(14),C(15)
End Proc
Procedure _GAMEON
Every 1 Proc _EVERYPROC
Every On
AN=0 : FIN=0 : PLANG=0 : XESC=0 : KS=False
' CIRC=3
CIRCANG=180 : CIRCDIST=64*(CSIZE+7)
BCOUNT=0 : BDIR=0
Repeat
T=PL
For C=0 To PL
If ANG(C)>265*1024 : Dec T : End If
If Extension_12_044C(X(C)/2048,Y(C)/2048)=0 and CON(C)>0
CON(C)=-CON(C)
End If
Next C
If T=-1 : FIN=1 : End If
TPLAYER=T
' Deletion by lines/polygons
If T>0 and GAMETYPE=0
Ink 0
X1=160+CSIN((CIRCANG+19) mod 360)/1024.0*(CIRCDIST/64+1)
Y1=128+CCOS((CIRCANG+19) mod 360)/1024.0*(CIRCDIST/64+1)
X2=160+CSIN((CIRCANG-19) mod 360)/1024.0*(CIRCDIST/64+1)
Y2=128+CCOS((CIRCANG-19) mod 360)/1024.0*(CIRCDIST/64+1)
X3=160+CSIN((CIRCANG+19) mod 360)/1024.0*(CIRCDIST/64+3)
Y3=128+CCOS((CIRCANG+19) mod 360)/1024.0*(CIRCDIST/64+3)
X4=160+CSIN((CIRCANG-19) mod 360)/1024.0*(CIRCDIST/64+3)
Y4=128+CCOS((CIRCANG-19) mod 360)/1024.0*(CIRCDIST/64+3)
Polygon X1,Y1 To X2,Y2 To X3,Y3 To X4,Y4
Add CIRCANG,12 : Add CIRCDIST,-3
CSIZE=CIRCDIST/64-6
End If
If T<=0 and KS=False
If PLANG=0 : Get Block 1,160-32,128,64,128 : End If
If PLANG<45 : Inc PLANG
Else
T=PL
For C=0 To PL
If Y(C)>(255+9)*2048 : FIN=1 : End If
Next C
If T=-1 : FIN=1 : End If
End If
SIZ=(132-CSIZE)/4
Screen 1
Put Block 1,0,0
Polygon 16,128 To 48,128 To XPLAT2(PLANG,SIZ),YPLAT(PLANG,SIZ) To XPLAT1(PLANG,SIZ),YPLAT(PLANG,SIZ)
Screen 0 : Screen Copy 1,0,0,64,128 To 0,160-32,128
Cls 4,160-18,256 To 160+18,320+64
End If
If KS=False : KS=Key State(69)
Else
If PLONK : Dec XESC : Paste Icon XESC,0,1 : End If
End If
Repeat : Until Timer>=1 : Timer=0
Until FIN=1
Every Off : Sprite Off
If KS=False
WIN=-1
For C=0 To PL
If ANG(C)<=265*1024 : WIN=C : End If
Next C
If WIN>-1
Inc WINS(WIN) : Sam Play %100,2,Rnd(2000)+8000
End If
End If
For N=8 To 15 : Colour N,$555 : Next N
Screen 2
For N=PL To 0 Step -1
SCORE$=Str$(WINS(N))
N1=4+Val(Mid$(SCORE$,Len(SCORE$)-1,1))
N2=4+Val(Right$(SCORE$,1))
X1=160-TWIDTH(N1-4) : X2=160
Paste Icon X1,N*24,N1 : Extension_12_058A X2,N*24,N2
Paste Icon 96,N*24,2 : Paste Icon 320-25-96,N*24,3
Next N
If PLONK=False : Paste Icon 64+12,192,18 : End If
Screen Swap : Wait Vbl
Screen 0
C=$555
Fade 4,C,C,C,C,C,C,C,C,0,0,0,0,$9F,$F33,$F0
Wait 40
For N=0 To PL : X(N)=108*32 : XSP(N)=0 : Next N
Repeat
OKAY=True
For N=0 To PL
Sprite N,X Hard(X(N)/32),Y Hard(N*24+9),8+SPRNUM(N)
If X(N)=108*32
Gosub 0+Abs(CON(N))
If A : Inc X(N) : End If
OKAY=False
Else
Add X(N),XSP(N)/2
' 321*16 is same as 160.5*32
If X(N)<321*16 : Inc XSP(N) : OKAY=False
Else
If XSP(N)>0 : Dec XSP(N) : OKAY=False : End If
End If
End If
Next N
If KS=False : KS=Key State(69) : End If
Wait Vbl
Until OKAY
Fade 2,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C
Wait 32
Screen 2 : Screen Swap : Wait Vbl : Extension_12_0380 -1
Screen 0
Sprite Off
Goto EN
1 Rem Joy 1
A=Fire(1) or(KS and Rnd(100)>97)
Return
2 Rem Joy 0
A=Fire(0) or(KS and Rnd(100)>97)
Return
3 Rem {[,}],>.
A=Key State(57) or(KS and Rnd(100)>97)
Return
4 Rem 6,7,F
A=Key State(35) or(KS and Rnd(100)>97)
Return
5 Rem LALT,LAMIGA,LSHIFT
A=Key State(96) or(KS and Rnd(100)>97)
Return
6 Rem Computer
A=False : If Rnd(100)>97 : A=True : End If
Return
EN:
End Proc
Procedure _EVERYPROC
Every On
Add AN,1,0 To 3 : Add CAR,1,0 To PL : Dec SAMREP
For N=0 To MXPL
XSPD=XSP(N)/16 : YSPD=YSP(N)/16
If CON(N)>-1
Add X(N),XSPD : Add Y(N),YSPD
If Sprite Col(N,0 To PL)
CO=Col(-1)
If HIT(CO)<>HIT(N) or HIT(CO)=0
If SAMREP<0
SAMREP=8
Volume %1,Min((Abs(XSP(N)/16)+Abs(XSP(CO)/16)+Abs(YSP(N)/16)+Abs(YSP(CO)/16))/64,63)
Sam Play %1,1,Rnd(4000)+3000
End If
Add X(N),-XSPD : Add Y(N),-YSPD
Add X(CO),-XSP(CO)/16 : Add Y(CO),-YSP(CO)/16
Swap XSP(N),XSP(CO) : Swap YSP(N),YSP(CO)
Add X(N),XSP(N)/16 : Add Y(N),YSP(N)/16
Add X(CO),XSP(CO)/16 : Add Y(CO),YSP(CO)/16
Sprite CO,X Hard(X(CO)/2048),Y Hard(Y(CO)/2048),ANG(CO)+SPRNUM(CO)
HIT(N)=CO : HIT(CO)=N
End If
Else HIT(N)=0
End If
XCAR= Extension_12_006A(X(N),11) : YCAR= Extension_12_006A(Y(N),11)
If N>=STLIM(AN) and N<ENLIM(AN)
Gosub 0+CON(N)
If L : Add ANG(N),1,0 To 31 : End If
If R : Add ANG(N),-1,0 To 31 : End If
If A
If SPD(N)<135 : Add SPD(N),45 : End If
Else SPD(N)=SPD(N)/2
End If
Add XSP(N),QSIN(ANG(N))*SPD(N)/128-XSPD+XSPD/2
Add YSP(N),QCOS(ANG(N))*SPD(N)/128-YSPD+YSPD/2
End If
Sprite N,X Hard(XCAR),Y Hard(YCAR),ANG(N)+SPRNUM(N)
Else
If ANG(N)<=265*1024
If ANG(N)<=265
If ANG(N)<32
Add ANG(N),42 : Sam Play %10,3,Rnd(2000)+8000
XSP(N)=XSP(N)*2 : YSP(N)=YSP(N)*2
End If
Sprite N,X Hard(X(N)/2048),Y Hard(Y(N)/2048),ANG(N)+SPRNUM(N)
Add ANG(N),32
Add X(N),XSPD : Add Y(N),YSPD
ANG(N)=ANG(N)*1024
Else ANG(N)=ANG(N)/1024
End If
Else Sprite Off N
End If
End If
Next N
Goto EN
1 Rem Joy 1
L=(Jleft(1) and KS=False) or(KS and Rnd(100)>97)
R=(Jright(1) and KS=False) or(KS and Rnd(100)>97)
A=Fire(1) or KS
Return
2 Rem Joy 0
L=(Jleft(0) and KS=False) or(KS and Rnd(100)>97)
R=(Jright(0) and KS=False) or(KS and Rnd(100)>97)
A=Fire(0) or KS
Return
3 Rem {[,}],>.
L=(Key State(26) and KS=False) or(KS and Rnd(100)>97)
R=(Key State(27) and KS=False) or(KS and Rnd(100)>97)
A=Key State(57) or KS
Return
4 Rem 6,7,F
L=(Key State(6) and KS=False) or(KS and Rnd(100)>97)
R=(Key State(7) and KS=False) or(KS and Rnd(100)>97)
A=Key State(35) or KS
Return
5 Rem LALT,LAMIGA,LSHIFT
L=(Key State(100) and KS=False) or(KS and Rnd(100)>97)
R=(Key State(102) and KS=False) or(KS and Rnd(100)>97)
A=Key State(96) or KS
Return
6 Rem Computer
RN=Rnd(100) : R=False : L=False : A=True
If RN=3 : A=False : End If
If KS=False
If DI(N)=0 or RN>95
ANP=((Rnd(1)+1)*2-3)
If ANP<>DI(N) and DI(N)<>0 : DI(N)=0
Else DI(N)=ANP
End If
ANP=ANP*8
Else ANP=DI(N)*8
End If
ANG=ANG(N)+ANP
If ANG>31 : Add ANG,-32 : End If
If ANG<0 : Add ANG,32 : End If
TNOP=(Abs(XSPD)+Abs(YSPD))/32
If Extension_12_044C(XCAR+(XSPD+QSIN(ANG)*TNOP)/2048,YCAR+(YSPD+QCOS(ANG)*TNOP)/2048)<=0
If Sgn(ANP)=-1 : R=False : L=True : DI=-1
Else R=True : L=False : DI=1
End If
If DI<>DI(N) and DI(N)<>0 : DI(N)=0 : End If
Else
If Sgn(ANP)=-1 : L=False : R=True : DI=1
Else L=True : R=False : DI=-1
End If
If DI<>DI(N) and DI(N)<>0 : DI(N)=0 : End If
End If
End If
' If all the other players are dead
If TPLAYER=0 and KS=False
If XCAR>160-16 and XCAR<160+16
A=False
If ANG(N)>28 or ANG(N)<4
A=True : L=False : R=False
If ANG(N)>30 or ANG(N)<2
A=True
If XCAR>160-4 and XCAR<160+4
If ANG(N)=31 : L=True : End If
If ANG(N)=1 : R=True : End If
Else
If XCAR<160 : L=True
Else R=True
End If
End If
Else
If ANG(N)<16 : R=True
Else L=True
End If
End If
Else
If ANG(N)<16 : R=True
Else L=True
End If
End If
End If
End If
Return
7 Rem The Ball
L=False : R=False : A=False
Dec BCOUNT
If TPLAYER<>0
FP=1
If BCOUNT<0 : FP= Extension_12_044C(XCAR,YCAR) : End If
If FP>3 : Inc WINS(FP-4) : BCOUNT=4 : SPRNUM(4)=318 : BDIR=0
Else
If FP=0 : BCOUNT=2 : BDIR=1 : End If
End If
If BCOUNT=0
X(N)=160*2048 : Y(N)=128*2048
XSP(N)=0 : YSP(N)=0
SPRNUM(4)=318 : BDIR=-1
Else
If BCOUNT>0 : XSP(N)=0 : YSP(N)=0 : End If
End If
If BDIR<>0
Add SPRNUM(4),BDIR
If SPRNUM(4)=318 : BCOUNT=1 : BDIR=0 : End If
If SPRNUM(4)=313 : BDIR=0 : End If
End If
Else SPRNUM(4)=319 : Sprite Off 4
End If
Return
EN:
End Proc